<template>
  <div class="map-popup">
    <div class="header">{{ feature.name }}</div>
    <div class="column-list">
      <div class="column-item" v-for="item in columns">
        <template v-if="item.type != 'image'">
          <div class="column-name">{{ item.name }}</div>
          <div class="column-value">{{ feature.properties[item.key] }}</div>
        </template>
        <template v-else>
          <n-image
            v-if="feature.properties[item.key]"
            class="preview-img"
            object-fit="contain"
            :width="200"
            :src="feature.properties[item.key]"
            alt=""
          />
        </template>
      </div>
    </div>
    <div class="bottom"></div>
  </div>
</template>

<script lang="ts" setup>
import { PropType } from "vue";

const props = defineProps({
  title: String,
  columns: Array<any>,
  feature: Object as PropType<any>,
});
</script>

<style lang="scss" scoped>
.map-popup {
  width: 240px;
  height: 200px;
  box-sizing: border-box;
  padding: 12px;
  display: flex;
  flex-direction: column;
}
.header {
  text-align: center;
  font-size: 18px;
  color: #fff;
}
.column-list {
  color: #fff;
  margin-top: 12px;
  flex: 1;
  .column-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
  }
}
.preview-img {
  height: 140px;
  width: 200px;
  object-fit: contain;
}
</style>
